// pages/person/teamDetail/teamDetail.js
import Tips from '../../../class/utils/Tips.js'
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    date: '',

  },

  // 日期选择器
  bindDateChange(e) {
    let that = this
    that.setData({
      date: e.detail.value,
      page: 1
    })
    console.log(that.data.date)
    wx.getStorage({
      key: 'userinfo',
      success: function(res) {
        console.log(res.data)
        Tips.loading()
        wx.request({
          url: app.globalData.api + "mysalse",
          data: {
            uid: res.data.id,
            datetime: that.data.date
          },
          success: function(res) {
            Tips.loaded()
            console.log('升级', res)
            let result = res.data.list
            that.setData({
              avatarurl: result.avatarurl,
              nickname: result.nickname,
              bonus: result.bonus,
              fen_bonus: result.fen_bonus,
              user_level_sales_price: result.user_level_sales_price,
              shi_title: result.shi_title,
              shi_price: result.shi_price
            })
          }

        })
      },
    })
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this
    var timestamp = Date.parse(new Date());
    var date = new Date(timestamp);
    //获取年份  
    var Y = date.getFullYear();
    //获取月份  
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
    //获取当日日期 
    let newdata = Y + '-' + M
    that.setData({
      date: newdata
    })
    // var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
    console.log("当前时间：" + Y + '-' + M);
    // console.log(getFullYear, getMonth)
    wx.getStorage({
      key: 'userinfo',
      success: function(res) {
        console.log(res.data)
        Tips.loading()
        wx.request({
          url: app.globalData.api + "mysalse",
          data: {
            uid: res.data.id,
            datetime: that.data.date
          },
          success: function(res) {
            Tips.loaded()
            console.log('升级', res)
            let result = res.data.list
            that.setData({
              avatarurl: result.avatarurl,
              nickname: result.nickname,
              bonus: result.bonus,
              fen_bonus: result.fen_bonus,
              user_level_sales_price: result.user_level_sales_price,
              shi_title: result.shi_title,
              shi_price: result.shi_price
            })
          }

        })
      },
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})